<?php

/*
	[Question&Answer] (C)2011-2099 .

	$Id: index.php 2011-11-21 10:15:10Z JS $
*/

error_reporting(E_ALL);
@set_magic_quotes_runtime(0);

$mtime = explode(' ', microtime());
$starttime = $mtime[1] + $mtime[0];

define('IN_QA', 'www');
define('QA_ROOT', dirname(__FILE__).'/');


unset($GLOBALS, $_ENV, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_ENV_VARS);
require QA_ROOT.'release/release.php';
if(!@include QA_ROOT.'config/init.cfg.php') {
	exit('The file <b>config/init.cfg.php</b> does not exist, perhaps because of QAenter has not been installed, <a href="install/index.php"><b>Please click here to install it.</b></a>.');
}

$_GET		= coreFun::daddslashes($_GET, 1, TRUE);
$_POST		= coreFun::daddslashes($_POST, 1, TRUE);
$_COOKIE	= coreFun::daddslashes($_COOKIE, 1, TRUE);
$_SERVER	= coreFun::daddslashes($_SERVER);
$_FILES		= coreFun::daddslashes($_FILES);
$_REQUEST	= coreFun::daddslashes($_REQUEST, 1, TRUE);


$c = coreFun::getgpc('c');
$a = coreFun::getgpc('a');
$c = empty($c) ? 'index' : $c;
$a = empty($a) ? 'index' : $a;

//补丁包目录
define('RELEASE_ROOT', '');

if(file_exists(QA_ROOT.RELEASE_ROOT.'model/base.php')) {
	require QA_ROOT.RELEASE_ROOT.'model/base.php';
} else {
	require QA_ROOT.'model/base.php';
}

if(in_array($c, array('app', 'index', 'user', 'tag','mail', 'version'))) {

	if(file_exists(QA_ROOT.RELEASE_ROOT."control/".IN_QA."/$c.php")) {
		include QA_ROOT.RELEASE_ROOT."control/".IN_QA."/$c.php";
	} else {
		include QA_ROOT."control/".IN_QA."/$c.php";
	}

	$control = new control();
	$method = 'on'.$a;
	if(method_exists($control, $method) && $a{0} != '_') {
		$data = $control->$method();
		echo is_array($data) ? $control->serialize($data, 1) : $data;
		exit;
	} elseif(method_exists($control, '_call')) {
		$data = $control->_call('on'.$a, '');
		echo is_array($data) ? $control->serialize($data, 1) : $data;
		exit;
	} else {
		exit('Action not found!');
	}
} else {
	exit('Control not found!');

}

